home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 120
/
Vol 120.iso
/
games
/
orbitrax.swf
/
scripts
/
DefineSprite_675
/
frame_1
/
DoAction.as
Wrap
Text File
|
2010-11-09
|
5KB
|
199 lines
function incSeg()
{
seg++;
seg2 = seg + 1;
if(seg >= gameMain.numPointsT - 1)
{
seg2 = 0;
}
if(seg >= gameMain.numPointsT)
{
seg = 0;
seg2 = 1;
}
}
function tTween()
{
t += speed;
if(t > 0.99)
{
t = 0;
incSeg();
speed = vSpeed;
mid1.x = gameMain.midT[seg].x;
mid1.y = gameMain.midT[seg].y;
point2.x = gameMain.pointsT[seg2]._x;
point2.y = gameMain.pointsT[seg2]._y;
mid2.x = gameMain.midT[seg2].x;
mid2.y = gameMain.midT[seg2].y;
}
_X = mid1.x * (1 - t) * (1 - t) + 2 * point2.x * (1 - t) * t + mid2.x * t * t;
_Y = mid1.y * (1 - t) * (1 - t) + 2 * point2.y * (1 - t) * t + mid2.y * t * t;
vx = _X - oldx;
vy = _Y - oldy;
oldx = _X;
oldy = _Y;
trot = Math.atan2(vy,vx) * 180 / 3.141592653589793;
diff = trot - _rotation;
if(diff > 180)
{
diff -= 360;
}
if(diff < -180)
{
diff += 360;
}
vrot += diff * 0.5;
vrot *= 0.8;
_rotation = _rotation + vrot;
if(main.gameStarted && twin._visible)
{
var i = 1;
while(i <= gameMain.hitZoneQty)
{
if(hitZone.hitTest(eval("gameMain.hitZone" + i)))
{
hitObjList = eval("gameMain.zoneArray" + i);
}
i++;
}
i = 0;
while(i < hitObjList.obsArray.length)
{
if(hitObjList.borderArray[i].addIt == "type1")
{
if(gameMain.checkObs(this,hitObjList.obsArray[i]))
{
this.onEnterFrame = cTween;
}
}
i++;
}
if(!gameMain.clock._visible)
{
if(gameMain.checkObs(this,gameMain.piste.car))
{
gameMain.allCar.car.gotoAndStop("bumpFront");
gameMain.bumpSnd.gotoAndPlay("bump");
this.onEnterFrame = cTween;
}
}
var i = 0;
while(i < hitObjList.borderArray.length)
{
if(hitObjList.borderArray[i].addIt == "type1")
{
if(gameMain.checkBorder(this,hitObjList.borderArray[i]))
{
lock = true;
delete this.onEnterFrame;
break;
}
}
i++;
}
}
if(!lock)
{
twin._x = _X;
twin._y = _Y;
twin._rotation = _rotation;
}
}
function cTween()
{
vx *= friction;
vy *= friction;
_X = _X + vx;
_Y = _Y + vy;
if(gameMain.swapObj.getDepth() < gameMain.elementMap.getDepth())
{
var i = 1;
while(i <= gameMain.hitZoneQty)
{
if(hitZone.hitTest(eval("gameMain.hitZone" + i)))
{
hitObjList = eval("gameMain.zoneArray" + i);
}
i++;
}
i = 0;
while(i < hitObjList.obsArray.length)
{
if(hitObjList.borderArray[i].addIt == "type1")
{
gameMain.checkObs(this,hitObjList.obsArray[i]);
}
i++;
}
i = 0;
while(i < gameMain.carArray.length)
{
if(!gameMain.clock._visible)
{
if(gameMain.checkObs(this,gameMain.carArray[i]))
{
gameMain.allCar.car.gotoAndStop("bumpFront");
gameMain.bumpSnd.gotoAndPlay("bump");
}
}
i++;
}
var i = 0;
while(i < hitObjList.borderArray.length)
{
if(hitObjList.borderArray[i].addIt == "type1")
{
if(gameMain.checkBorder(this,hitObjList.borderArray[i]))
{
lock = true;
hitObjList.obsArray.push(this);
delete this.onEnterFrame;
break;
}
}
i++;
}
}
if(!lock)
{
twin._x = _X;
twin._y = _Y;
twin._rotation = _rotation;
}
if(Math.round(vx) == 0 && Math.round(vy) == 0)
{
t = 0;
if(collSeg != seg2)
{
incSeg();
speed = vSpeed2;
collSeg = seg2;
}
mid1.x = _X;
mid1.y = _Y;
point2.x = gameMain.pointsT[seg2]._x;
point2.y = gameMain.pointsT[seg2]._y;
mid2.x = gameMain.midT[seg2].x;
mid2.y = gameMain.midT[seg2].y;
vx = vy = 0;
onEnterFrame = tTween;
}
}
lock = false;
m = 60;
ray = 20;
friction = 0.9;
vx = vy = 0;
vSpeed = 0.04;
vSpeed2 = vSpeed / 2;
seg = 0;
seg2 = 1;
mid1 = new Object();
mid2 = new Object();
point2 = new Object();
coll = false;
t = 1;
this.onEnterFrame = tTween;
stop();